#-------------------------------------------------------------------------------
# extlibs/DevIL
#-------------------------------------------------------------------------------
INCLUDE_DIRECTORIES(
    ${Nebula3_SOURCE_DIR}/extlibs/DevIL/
    ${Nebula3_SOURCE_DIR}/extlibs/DevIL/src-IL/include/
    ${Nebula3_SOURCE_DIR}/extlibs/DevIL/src-ILU/include/
    ${Nebula3_SOURCE_DIR}/extlibs/DevIL/IL/
    ${Nebula3_SOURCE_DIR}/extlibs/zlib/
)
SET(extlibs_devil_include
    IL/config.h
    IL/devil_internal_exports.h
    IL/il.h
    IL/il_wrap.h
    IL/ilu.h
    IL/ilu_region.h
    IL/ilut.h
)
SET(extlibs_devil_il_include
    src-IL/include/altivec_common.h
    src-IL/include/altivec_typeconversion.h
    src-IL/include/il_alloc.h
    src-IL/include/il_bits.h
    src-IL/include/il_bmp.h
    src-IL/include/il_dcx.h
    src-IL/include/il_dds.h
    src-IL/include/il_doompal.h
    src-IL/include/il_endian.h
    src-IL/include/il_exr.h
    src-IL/include/il_files.h
    src-IL/include/il_gif.h
    src-IL/include/il_hdr.h
    src-IL/include/il_icns.h
    src-IL/include/il_icon.h
    src-IL/include/il_internal.h
    src-IL/include/il_jp2.h
    src-IL/include/il_jpeg.h
    src-IL/include/il_lif.h
    src-IL/include/il_manip.h
    src-IL/include/il_mdl.h
    src-IL/include/il_pal.h
    src-IL/include/il_pcx.h
    src-IL/include/il_pic.h
    src-IL/include/il_pnm.h
    src-IL/include/il_psd.h
    src-IL/include/il_psp.h
    src-IL/include/il_q2pal.h
    src-IL/include/il_register.h
    src-IL/include/il_rle.h
    src-IL/include/il_sgi.h
    src-IL/include/il_stack.h
    src-IL/include/il_states.h
    src-IL/include/il_targa.h
)
SET(extlibs_devil_il_src
    src-IL/src/altivec_common.c
    src-IL/src/altivec_typeconversion.c
    src-IL/src/il_alloc.c
    src-IL/src/il_bits.c
    src-IL/src/il_bmp.c
    src-IL/src/il_convbuff.c
    src-IL/src/il_convert.c
    src-IL/src/il_cut.c
    src-IL/src/il_dcx.c
    src-IL/src/il_dds.c
    src-IL/src/il_dds-save.c
    src-IL/src/il_devil.c
    src-IL/src/il_doom.c
    src-IL/src/il_endian.c
    src-IL/src/il_error.c
    src-IL/src/il_fastconv.c
    src-IL/src/il_files.c
    src-IL/src/il_gif.c
    src-IL/src/il_hdr.c
    src-IL/src/il_header.c
    src-IL/src/il_icns.c
    src-IL/src/il_icon.c
    src-IL/src/il_internal.c
    src-IL/src/il_io.c
    src-IL/src/il_jp2.c
    src-IL/src/il_jpeg.c
    src-IL/src/il_lif.c
    src-IL/src/il_main.c
    src-IL/src/il_manip.c
    src-IL/src/il_mdl.c
    src-IL/src/il_mng.c
    src-IL/src/il_neuquant.c
    src-IL/src/il_pal.c
    src-IL/src/il_pcd.c
    src-IL/src/il_pcx.c
    src-IL/src/il_pic.c
    src-IL/src/il_pix.c
    src-IL/src/il_png.c
    src-IL/src/il_pnm.c
    src-IL/src/il_profiles.c
    src-IL/src/il_psd.c
    src-IL/src/il_psp.c
    src-IL/src/il_pxr.c
    src-IL/src/il_quantizer.c
    src-IL/src/il_raw.c
    src-IL/src/il_rawdata.c
    src-IL/src/il_register.c
    src-IL/src/il_rle.c
    src-IL/src/il_sgi.c
    src-IL/src/il_stack.c
    src-IL/src/il_states.c
    src-IL/src/il_targa.c
    src-IL/src/il_tiff.c
    src-IL/src/il_utility.c
    src-IL/src/il_wal.c
    src-IL/src/il_xpm.c
)
SET(extlibs_devil_ilu_include
    src-ILU/include/ilu_alloc.h
    src-ILU/include/ilu_filter.h
    src-ILU/include/ilu_internal.h
    src-ILU/include/ilu_mipmap.h
    src-ILU/include/ilu_region.h
    src-ILU/include/ilu_states.h
)
SET(extlibs_devil_ilu_src
    src-ILU/src/ilu_alloc.c
    src-ILU/src/ilu_error.c
    src-ILU/src/ilu_filter.c
    src-ILU/src/ilu_filter_rcg.c
    src-ILU/src/ilu_internal.c
    src-ILU/src/ilu_main.c
    src-ILU/src/ilu_manip.c
    src-ILU/src/ilu_mipmap.c
    src-ILU/src/ilu_noise.c
    src-ILU/src/ilu_region.c
    src-ILU/src/ilu_rotate.c
    src-ILU/src/ilu_scale2d.c
    src-ILU/src/ilu_scale3d.c
    src-ILU/src/ilu_scale.c
    src-ILU/src/ilu_scaling.c
    src-ILU/src/ilu_states.c
    src-ILU/src/ilu_utilities.c
)

SET(extlibs_devil_SRCS
    ${extlibs_devil_include}
    ${extlibs_devil_il_include}
    ${extlibs_devil_il_src}
    ${extlibs_devil_ilu_include}
    ${extlibs_devil_ilu_src}
)

SOURCE_GROUP(IL FILES ${extlibs_devil_include})

# compile .c files using the C++ compiler
#SET_SOURCE_FILES_PROPERTIES(${extlibs_devil_SRCS} PROPERTIES LANGUAGE CXX)

ADD_LIBRARY(devil STATIC ${extlibs_devil_SRCS})
N_SET_COMPILER_DEFAULTS()
ADD_DEFINITIONS(/DIL_STATIC_LIB)
IF(WIN32)
    ADD_DEFINITIONS(/D_WIN32)
ENDIF()
IF(MSVC)
    # disable irritating warnings that should be fixed in the DevIL source
    # C4267: conversion from 'size_t' to 'ILint', possible loss of data.
    # C4996: The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name.
    # C4311: pointer truncation from 'ILubyte *' to 'long'.
    ADD_DEFINITIONS(/D_CRT_SECURE_NO_WARNINGS /wd4267 /wd4996 /wd4311)
ENDIF()
